<script setup>
import { RouterView } from 'vue-router'
</script>

<template>
  <v-app>
    <v-main>
      <router-view />
    </v-main>
    
    <!-- 全局提示弹窗 -->
    <v-snackbar
      v-model="showLoginAlert"
      color="warning"
      timeout="3000"
      location="top"
    >
      <div class="d-flex align-center">
        <v-icon start>mdi-alert-circle</v-icon>
        <span>请先登录后再访问此页面</span>
      </div>
      
      <template v-slot:actions>
        <v-btn
          color="white"
          text
          @click="showLoginAlert = false"
        >
          关闭
        </v-btn>
        <v-btn
          color="white"
          text
          @click="goToLogin"
        >
          去登录
        </v-btn>
      </template>
    </v-snackbar>
  </v-app>
</template>

<style>
#app {
  font-family: 'Roboto', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
}

/* Logo样式 */
.logo-img {
  border-radius: 4px;
  object-fit: contain;
}

.logo-img:hover {
  transform: scale(1.05);
  transition: transform 0.2s ease-in-out;
}
</style>

<script>
export default {
  name: 'App',
  data() {
    return {
      showLoginAlert: false
    }
  },
  methods: {
    showLoginMessage() {
      this.showLoginAlert = true
    },
    goToLogin() {
      this.showLoginAlert = false
      this.$router.push('/login')
    }
  },
  mounted() {
    // 将方法挂载到全局，供路由守卫调用
    this.$root.showLoginMessage = this.showLoginMessage
  }
}
</script>
